import Person from './person'

export default class Order {
  constructor ({ id, sender, receiver, state, code } = {}) {
    this.id = id || -1
    this.state = state || 1
    this.code = code || -1
    this.sender = sender || new Person()
    this.receiver = receiver || new Person()
  }
}

export function createOrder ({
  id, senderName, senderPhone, senderAddress,
  receiverName, receiverPhone, receiverAddress,
  state, code
}) {
  const sender = new Person({
    name: senderName,
    phone: senderPhone,
    address: senderAddress
  })
  const receiver = new Person({
    name: receiverName,
    phone: receiverPhone,
    address: receiverAddress
  })
  return new Order({
    id,
    sender,
    receiver,
    state,
    code
  })
}
